# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=kicad-library
pkgver=8.0.6
pkgrel=0
pkgdesc="KiCad component and footprint libraries"
url="https://kicad.github.io/"
# limited by kicad
arch="noarch !armv7 !armhf !riscv64 !s390x"
license="GPL-3.0-or-later"
makedepends="cmake samurai"
depends="kicad"
subpackages="$pkgname-3d:three_d"
source="
	https://gitlab.com/kicad/libraries/kicad-symbols/-/archive/$pkgver/kicad-symbols-$pkgver.tar.gz
	https://gitlab.com/kicad/libraries/kicad-footprints/-/archive/$pkgver/kicad-footprints-$pkgver.tar.gz
	https://gitlab.com/kicad/libraries/kicad-packages3D/-/archive/$pkgver/kicad-packages3D-$pkgver.tar.gz
	"
options="!check" # package only provides data files, so not tests possible

build() {
	cd "$srcdir"/kicad-symbols-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build

	cd "$srcdir"/kicad-footprints-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build

	cd "$srcdir"/kicad-packages3D-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install "$srcdir"/kicad-symbols-$pkgver/build
	DESTDIR="$pkgdir" cmake --install "$srcdir"/kicad-footprints-$pkgver/build
}

three_d() {
	pkgdesc="3D models for KiCad component and footprint libraries"
	depends="$pkgname"
	DESTDIR="$subpkgdir" cmake --install "$srcdir"/kicad-packages3D-$pkgver/build

	# Remove .step version of 3D models; only .wrl versions are needed
	find "$subpkgdir" -name '*.step' -exec rm {} \;
}

sha512sums="
5404b534f687e91639ffdfbada31ee6ffa126f132cefff08e961d3eb5fd46c0ad8b5c1043650b5886535d9900df6beed47612669de90cd5287856104c52d9e03  kicad-symbols-8.0.6.tar.gz
c5fb0c710a9a0ff2fb6bc7249db8714fc7050f8b198d8ecb22dbaf92ca6c9a994af3297f1156adca4373037bbdc0ed6b09f9a6c258326918bd675efdd35c17b1  kicad-footprints-8.0.6.tar.gz
c77fc80e550a72737dd5bcd4ccf373e69107ed47c9c9bac3ba500a22412ce8a7e54c6d7dd7c2d303af6485e59e5267291358d23b734ae170452a76aab1e25953  kicad-packages3D-8.0.6.tar.gz
"
